package com.blog.config;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.orm.hibernate5.HibernateTransactionManager;

@Configuration
@Import(value={DataSourceConfig.class,HibernateConfig.class,RedisConfig.class})
public class AppContextConfig {
    @Autowired
    private SessionFactory sessionFactory;

    @Bean(name="transactionManager")
    public HibernateTransactionManager transactionManager(){
        HibernateTransactionManager htm = new HibernateTransactionManager();
        htm.setSessionFactory(sessionFactory);
        return htm;
    }
}
